package com.rabbiter.oes.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rabbiter.oes.entity.Replay;
import com.rabbiter.oes.mapper.ReplayMapper;
import com.rabbiter.oes.service.ReplayService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 留言回复
 */
@Service
public class ReplayServiceImpl extends ServiceImpl<ReplayMapper, Replay> implements ReplayService {

    /**
     * 获取全部回复
     * @return
     */
    @Override
    public List<Replay> findAll() {
        return baseMapper.selectList(Wrappers.lambdaQuery(Replay.class));
    }

    /**
     * 根据留言id获取回复信息
     * @param messageId
     * @return
     */
    @Override
    public List<Replay> findAllByMessageId(Integer messageId) {
        return baseMapper.findAllByMessageId(messageId);
    }

    @Override
    public Replay findById(Integer replayId) {
        return baseMapper.selectById(replayId);
    }

    @Override
    public int delete(Integer replayId) {
        return baseMapper.deleteById(replayId);
    }

    @Override
    public int update(Replay replay) {
        return baseMapper.updateById(replay);
    }

    @Override
    public int add(Replay replay) {
        return baseMapper.insert(replay);
    }
}
